<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@page import="tpcar.ejb.Personne"%>
<%@page import="java.util.*"%>
<html>
<head><title>User interface with JSP</title></head>
<body>
<h1>Looking for someone ?</h1><br>
<form action="/tpcar/consultservlet" method ="get">
<p>
Name:&nbsp;<input type="text" name="prefix"/>
<br/><input type="submit" name="searchPerson" value ="Search !"/>
<br/><input type="submit" name="searchallPerson" value ="Search All !"/>
</p>
</form>
<h1>Looking for a card ?</h1><br>
<form method ="get">
<p>
Name:&nbsp;<input type="text" name="prefix"/>
<br/><input type="submit" name="searchCard" value ="Search !"/>
<br/><input type="submit" name="searchallCard" value ="Search All !"/>
</p>
</form>

<c:if test="${not empty param.searchallPerson || not empty param.searchallPerson }">
	
	<%-- if/else condition --%>
   	<c:choose>
      		<c:when test="${not empty param.searchallPerson}">
			<h2> Current List  </h2>
                </c:when>
        	<c:otherwise>
			<h2> Search Result for <%=request.getParameter("prefix")%> </h2>
                </c:otherwise>
	</c:choose>
	<jsp:useBean id="resultBean" scope="request" class="java.util.ArrayList" >
	</jsp:useBean>
	<c:if test="${fn:length(resultBean) == 0}">
		<p><strong> No match found ! </strong></p>
	</c:if>
	<c:forEach var="p" items="<%=resultBean %>">
		<h4> <c:out value="${p.nom}"  />&nbsp;<c:out value="${p.prenom}"  /></h4>
		<ul>
		<li>Place of Birth: <c:out value="${p.lieuNaissance}"  /></li>
		<li>Date of Birth: <c:out value="${p.dateNaissance}" /></li>
		<li>Gender: <c:out value="${p.sexe}" /> </li>
		</ul>
	</c:forEach>
</c:if>
</body>
</html>
